﻿'Params
'artist (Required (unless mbid)] : The artist name
'mbid (Optional) : The musicbrainz id for the artist
'autocorrect[0|1] (Optional) : Transform misspelled artist names into correct artist names, returning the correct version instead. The corrected artist name will be returned in the response.
'api_key (Required) : A Last.fm API key.

'Auth
' This service does not require authentication. 

Public Structure ArtistGetTopTagsResponse
    Public tags() As Tag
End Structure

Public Class ArtistGetTopTags
	Inherits BaseRequest
	Dim artist As String = ""
	Dim mbid As String = ""
	Dim autocorrect As String = ""

	Public xmlresponse As XDocument = Nothing

	Public Sub New(artist As String, mbid As String, autocorrect As String)
		Me.artist = artist
		Me.mbid = mbid
		Me.autocorrect = autocorrect
	End Sub

	Public Sub sendRequest()
        ClearMembers()

        AddMember("method", "artist.getTopTags")

        AddMember("artist", artist, String.IsNullOrEmpty(mbid))
        AddMember("mbid", mbid, False)
        AddMember("autocorrect", autocorrect, False)

        AddMember("api_key", My.Settings.api_key, False)

        xmlresponse = sendGETResponse(False)
	End Sub

	Public Function getResponse() As ArtistGetTopTagsResponse
        Dim response As ArtistGetTopTagsResponse = Nothing
        Dim count As Integer
        Try
            count = xmlresponse.<lfm>.<toptags>.<tag>.Count()
        Catch ex As Exception
            Return response
        End Try
        If (count > 0) Then
            ReDim response.tags(count - 1)
            For i As Integer = 0 To count - 1
                response.tags(i) = New Tag(xmlresponse.<lfm>.<toptags>.<tag>(i))
            Next
        End If
        Return response
		Return New ArtistGetTopTagsResponse
	End Function

End Class
